package com.heima.kafka.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * Kafka主题消费者
 */
@Component
public class ConsumerListener {

    @KafkaListener(topics = "testOutTopic")
    //@KafkaListener(topicPartitions = {@TopicPartition(topic = "testTopic", partitions = {"0"})})
    public void msg(ConsumerRecord<String,String> consumerRecord){
        if(consumerRecord!=null){
            System.out.println(consumerRecord.key() + "==>" + consumerRecord.value() + "==>" + consumerRecord.offset());
        }
    }
}
